import { getAreaObj, uploadType } from '@/utils/util'
//限制不得早于当前
// const limitStartDisabled = (date) => {
//   let now = (new Date()).getTime()
//   let other = date.getTime()
//   return other < now - 1000 * 60 * 60 * 24
// }
export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '所属区域',
			prop: 'crAreas',
			type: 'AplidAreaSelect',
			span: 8,
		},
		{
			label: '委托单位名称',
			prop: 'providerName',
			type: 'input',
			span: 8,
		},
		{
			label: '统一社会信用代码',
			prop: 'creditCode',
			type: 'input',
			span: 8,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		// { type: 'selection', reserveSelection: true },
		{ label: '所属区', prop: 'registerAreaName' },
		{ label: '单位名称', prop: 'providerName' },
		{ label: '统一社会信用代码', prop: 'creditCode' },
		{ label: '负责人', prop: 'contactUserName' },
		{ label: '联系方式', prop: 'contactUserPhone' },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_dpServiceProvider_page',
	// add: 'view_omProjectManagement_add',
	// edit: 'view_omProjectManagement_edit',
	// delete: 'view_omProjectManagement_del',
	// authArea: 'authArea',
}
export const baseConfig = {
	pageName: '委托单位-养老行业服务商',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'sampleTime',
	exportMqTopic: '/ning/export/',
	api,
	auth: {
		...api,
	},
	paramsObj: {
		isWithAuth:0,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '添加',
			type: 'primary',
			operate: 'add',
			// auth: api.add,
			auth: 'view_omProjectManagement_add',
			text: true,
			show: true,
		},
	],
	beforeOnLoadFormate: async (params) => {
		console.log(params, 'params')
		if (params.projectTimeBetween) {
			params.projectTimeBetween = params.projectTimeBetween.join(',')
		} else {
			params.projectTimeBetween = undefined
		}
		return new Promise((resolve, reject) => {
			const areaObj: any = getAreaObj(params.areas)
			const crAreasareaObj: any = getAreaObj(params.crAreas, 'register')
			resolve({
				...params,
				...areaObj,
				...crAreasareaObj,
				areas: undefined,
				crAreas: undefined,
			})
		})
	},
	dialogConfig: {
		width: '55%',
	},
	searchConfig,
	tableConfig,
}
